import os
import zipfile

print("开始压缩 !\n")

dirname = './'
zip_name = 'di-manager-extension.zip'
with zipfile.ZipFile(zip_name, 'w') as z:
    for root, dirs, files in os.walk(dirname):
        for file in files:
            if file.endswith('js') or file.endswith('css') or file.endswith('html') or file.endswith('json'):
                file_path = os.path.join(root, file)
                relative_path = file_path[len(dirname) + 1: len(file_path)]

                print('压缩文件: ' + relative_path)
                z.write(file_path, relative_path)

print("\n压缩完成 !")
